package de.mroedig.appindiesonne.menu;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TimePicker;
import de.mroedig.appindiesonne.R;

public class ZeitWaehlen extends Activity {

	private DatePicker datePicker;
	private TimePicker timePicker;

	private Button weiterButton;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.zeitwaehlen);

		this.datePicker = (DatePicker) this.findViewById(R.id.datumPicker);
		this.timePicker = (TimePicker) this.findViewById(R.id.zeitPicker);

		this.weiterButton = (Button) this.findViewById(R.id.zeitweiterbutton);
		this.weiterButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				SharedPreferences mPrefs = ZeitWaehlen.this
						.getSharedPreferences("appInDieSonnePrefs",
								MODE_PRIVATE);
				Editor editor = mPrefs.edit();

				editor.putInt("stunde",
						ZeitWaehlen.this.timePicker.getCurrentHour());
				editor.putInt("monat", ZeitWaehlen.this.datePicker.getMonth());

				editor.commit();

				Intent intent = new Intent(ZeitWaehlen.this, Sonnenschutz.class);

				ZeitWaehlen.this.startActivity(intent);

			}
		});

	}
}
